This section describes the command uxset var (UXSETVAR on OS/400) which enables to carry-over variables values within a session.
Carry-over of the values of variables within a session is not automatic. By default, if nothing is done, the value of the variable is not carried over and the engine applies the rules for assigning values by default. The carry-over of a value may be requested by executing the command uxset var (UXSETVAR on OS/400) in the Uproc’s CL or in post-processing (U_POST_UPROC).
The variable transfer within a session is done by the execution of the command. If the next Uproc in the session is not submitted (for example in case of an optional task), the variables will be transferred to the child Uproc of the skipped Uproc.
The command syntax is as follows:
uxset var [level ALL | level INTER]|[var[=val] var[=val] ...]
Description of Items
level ALL | level INTER
(Optional) In an overall way, specifies the kind of carry-over:
level ALL: to carry over the values of the variables of the parent Uproc known from the child Uproc (the values carried over are those known at the beginning of the parent Uproc execution).
Default: level ALL
VAR=VAL
(Optional) Specifies those variables which should be carried over and eventually their new value. VAR is the variable’s name and VAL the value which will be transmitted to the child Uproc.
On UNIX/Linux, a variable name cannot start with a number (operating system restriction).
The " " enclosing a string is needed to carry over the spaces characters in the string; if you don't have a space in your string they are not needed. For instance:
uxset var VARDATE=2010/11/30 VARTXT="TEST TEST" VARNUM=555
Examples
To carry over all variables of the parent Uproc known from the child Uproc:
uxset var
Example 1
We have three Uprocs A, B, C. All have the same default variables: Var1, Var2, Var3.
Uproc A has a script which contains: uxset var level ALL
Uproc B has a script which contains: uxset var level INTER
Uproc C has a script which displays the variables.
In this case the script will display the values for Var1, Var2, Var3 of Uproc A, which were transmitted to Uproc B using the "uxset var level ALL" command, then carried over to Uproc C using the "uxset var level INTER" command.
In other words "uxset var level INTER" carries over only the information transmitted from a parent Uproc, and the carry over could be cascaded between multiple Uprocs using "uxset var level INTER" command.
Example 2
We have three Uprocs X, Y, Z.
Uproc X variables: Var1=Val1x, Var2=Val2x, Var3=Val3x
Uproc Y variables: Var1=Val1y, Var2=Val2y, Var3=Val3y
Uproc Z variables: Var1=Val1z, Var2=Val2z, Var3=Val3z
All have the same default variables: Var1=Val1, Var2=Val2, Var3=Val3
Uproc X has a script which contains: uxset var Var1=NewValue
Uproc Y has a script which contains: uxset var level INTER
Uproc Z has a script which displays the variables.
In this case the script will display the values NewValue, Val2z, and Val3z. In this case Uproc X transmitted NewValue to Uproc Y, and NewValue was carried over to Uproc Z using the "uxset var level INTER" command.
Recover Variables on OS/400
The variables are not implicitly recovered in classic OS/400 programs. The command UXGETVAR allows the user to recover the variable value passed from a UXSETVAR or UXORDRE command in a DCL variable.
Syntax:
UXGETVAR VAR('UPRWRD') DCLVAR(&VARVALUE)
This command must be used in the CL. It accepts two parameters:
In qsh, the var variable can be used directly in the $var shell variable.